package com.sys.user.service;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import com.sys.api.Service.UserService;
import com.sys.common.ZuelResult;
import com.sys.exception.ServiceException;
import com.sys.pojo.OrderUser;
import com.sys.user.dao.UserDao;

/**
 * @author 鸣濑白羽
 * @class 用户操作实现
 * @data 2021.4.4
 * */
@Service
public class UserServiceImpl implements UserService {

	@Autowired
	private UserDao dao;
	
	@Autowired
    private RedisTemplate<String, Object> redisTemplate;
	
	@Override
	public ZuelResult userRegister(OrderUser user) throws ServiceException {
		// TODO Auto-generated method stub
		if (user.getUsername()==null || user.getPasswords()==null) {
			throw new ServiceException("填写的信息不完整");
		}
		OrderUser newUser = new OrderUser();
		newUser.setState("0");
		newUser.setEmail(user.getEmail());
		newUser.setUsername(user.getUsername());
		newUser.setPasswords(user.getPasswords());
		dao.save(newUser);
		redisTemplate.delete("manager:users::getAllUser()");
		return ZuelResult.ok(null, "注册成功") ;
	}

	

	
}
